package com.leyou.client;

import com.leyou.common.dto.PageDTO;
import com.leyou.item.dto.*;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @author mySun
 * @create 2021-07-21 17:23
 */
@FeignClient("item-service")
public interface ItemClient {

    @GetMapping("/goods/spu/page")
    PageDTO<SpuDTO> pageSpu(
            @RequestParam(value = "page",defaultValue = "1")Long curPage,
            @RequestParam(value = "rows",defaultValue = "5")Long rows,
            @RequestParam(value = "brandId",required = false)Long bid,
            @RequestParam(value = "categoryId",required = false)Long cid,
            @RequestParam(value = "id",required = false)Long sid,
            @RequestParam(value = "saleable",required = false)Boolean saleable
    );



    @GetMapping("/goods/spec/value")
    List<SpecParamDTO> querySpecsValues(
            @RequestParam("id") Long sid,
            @RequestParam(value = "searching",required = false)Boolean isSearching);


    /**
     * 根据品牌id集合查询品牌集合
     * @return
     */
    @GetMapping("/brand/list")
    List<BrandDTO> queryBrandByBrandIds(@RequestParam("ids") List<Long> ids);


    @GetMapping("/category/list")
    List<CategoryDTO> queryCategoryByIds(@RequestParam("ids") List<Long> ids);

    /**
     * 根据id查询商品
     * @param id 商品id
     * @return
     */
    @GetMapping("/goods/spu/{id}")
    SpuDTO querySpuById(@PathVariable("id")Long sid);

    /**
     * 根据商品sid查询商品细节
     * @param sid
     * @return
     */
    @GetMapping("/goods/spu/detail")
    SpuDetailDTO queryDetailBySid(@RequestParam("id") Long sid);

    /**
     * 根据spuID查询sku的集合
     * @param sid 商品id
     * @return
     */
    @GetMapping("/goods/sku/of/spu")
    List<SkuDTO> listSkuBySid(@RequestParam("id") Long sid);

    /**
     * 根据id查询品牌
     * @param id 品牌id
     * @return
     */
    @GetMapping("/brand/{id}")
    BrandDTO queryBrandById(@PathVariable("id")Long id);

    /**
     *根据分类id查询规格组及组内参数
     * @param cid 分类id
     * @return
     */
    @GetMapping("/spec/list")
    List<SpecGroupDTO> listGroupAndParamByCid(@RequestParam("id")Long cid);
}
